package com.ssy.lingxi.search.entity;

import com.ssy.lingxi.common.constant.Constants;
import com.ssy.lingxi.search.entity.channel.ChannelCommodityMember;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.*;

import java.io.Serializable;
import java.util.List;

/**
 * 商品详情响应类
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/6/28
 */
@Data
@Document(indexName = Constants.ES_COMMODITY_INDEX)
@Setting(settingPath = "elasticsearch/settings.json")
public class Commodity implements Serializable {
    private static final long serialVersionUID = 2832532226028633662L;
    /**
     * 主键id
     */
    private Long id;

    /**
     * 会员品类
     */
    private CustomerCategory customerCategory;

    /**
     * 品牌
     */
    private Brand brand;

    /**
     * 商品名称
     */
    @MultiField(mainField = @Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_max_word"),
            otherFields = @InnerField(suffix = "inner", type = FieldType.Text, analyzer = "pinyin"))
    private String name;

//    /**
//     * 商品名称(用于自动补全)
//     */
//    @CompletionField(analyzer = "ik_pinyin_analyzer", searchAnalyzer = "keyword", contexts = @CompletionContext(name = "shopId_tab", path = "commodityShopList.shopId", type = ContextMapping.Type.CATEGORY))
//    private Completion tagsName;

    /**
     * 商品标语
     */
    @Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_max_word")
    private String slogan;

    /**
     * 商品卖点
     */
    @Field(type = FieldType.Text, searchAnalyzer = "ik_smart", analyzer = "ik_max_word")
    private String[] sellingPoint;

    /**
     * 是否不限制区域
     */
    @Field(type = FieldType.Boolean)
    private Boolean isAllArea;

    /**
     * 归属地市
     */
    @Field(type = FieldType.Nested)
    private List<CommodityArea> commodityAreaList;

    /**
     * 商品属性
     */
    private List<CommodityAttribute> commodityAttributeList;

    /**
     * 计量单位
     */
    private String unitName;

    /**
     * 副价格计量单位
     */
    private String subUnitName;

    /**
     * 最小起订
     */
    @Field(type = FieldType.Double)
    private Double minOrder;

    /**
     * 产品定价：1-现货价格, 2-价格需要询价, 3-积分兑换商品
     */
    @Field(type = FieldType.Integer)
    private Integer priceType;

    /**
     * 是否允许使用会员折扣价购买
     */
    @Field(type = FieldType.Boolean)
    private Boolean isMemberPrice;

    /**
     * 最小(价格/积分)
     */
    @Field(type = FieldType.Double)
    private Double min;

    /**
     * 最大(价格/积分)
     */
    @Field(type = FieldType.Double)
    private Double max;

    /**
     * 税率
     */
    private Double taxRate;

    /**
     * 商品主图
     */
    private String mainPic;

    /**
     * 商品单价和图片
     */
    private List<CommodityUnitPricePic> unitPricePicList;

    /**
     * 是否跨境商品
     */
    private Boolean isCrossBorder = false;

    /**
     * 商品描述
     */
    private CommodityRemark commodityRemark;

    /**
     * 物流信息
     */
    private Logistics logistics;

    /**
     * 是否开发票
     */
    @Field(type = FieldType.Boolean)
    private Boolean isInvoice;

    /**
     * 唛头
     */
    private String marks;

    /**
     * 包装清单
     */
    private String packing;

    /**
     * 售后服务
     */
    private String afterService;

    /**
     * 店铺id
     */
    @Field(type = FieldType.Keyword)
    private Long storeId;

    /**
     * 店铺名称
     */
    private String storeName;

    /**
     * 店铺logo
     */
    private String storeLogo;

    /**
     * 会员id
     */
    @Field(type = FieldType.Long)
    private Long memberId;

    /**
     * 会员名称
     */
    private String memberName;

    /**
     * 会员角色id
     */
    @Field(type = FieldType.Long)
    private Long memberRoleId;

    /**
     * 会员角色名称
     */
    private String memberRoleName;

    /**
     * 上架商城
     */
    @Field(type = FieldType.Object)
    private List<CommodityShop> commodityShopList;

    /**
     * 会员商品上架时间
     */
    @Field(type = FieldType.Long)
    private Long publishTime;

    /**
     * 店铺信用积分
     */
    @Field(type = FieldType.Integer)
    private int creditScore;

    /**
     * 已售数量(会员商品)
     */
    private List<CommoditySoldCount> commoditySoldCountList;

    /**
     * 上游商品id
     */
    private Long upperCommodityId;

    /**
     * 上游供应会员id
     */
    private Long upperMemberId;

    /**
     * 上游供应会员名称
     */
    private String upperMemberName;

    /**
     * 上游供应会员角色id
     */
    private Long upperMemberRoleId;

    /**
     * 上游供应会员角色名称
     */
    private String upperMemberRoleName;

    /**
     * 送货周期
     */
    @Field(type = FieldType.Integer)
    private Integer sendCycle;

    /********************************** 价格策略 *****************************************************/

    /**
     * 是否存在价格策略
     */
    @Field(type = FieldType.Boolean)
    private Boolean isUnitPriceStrategy = false;

    /**
     * 商品价格策略
     */
    @Field(type = FieldType.Object)
    private List<UnitPriceStrategy> unitPriceStrategyList;


    /********************************** 渠道商品标识属性 ***********************************************/

    /**
     * 渠道商品对应的下级渠道会员
     */
    @Field(type = FieldType.Object)
    private List<ChannelCommodityMember> memberList;

    /********************************** SEO优化 ***********************************************/

    /**
     * SEO优化: title
     */
    private String title;

    /**
     * SEO优化: description
     */
    private String description;

    /**
     * SEO优化: keywords
     */
    private String keywords;
}
